package com.wu.Backstage.entity;

import com.wu.Backstage.entity.Po.CommodityEntityPo;
import com.wu.Backstage.entity.Po.OrderDetailsPo;
import com.wu.Backstage.entity.Po.ShoppingCartPo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import javax.transaction.Transactional;
import java.util.List;


@Transactional
public interface orderDateEntity extends JpaRepository<OrderDetailsPo, Integer> {


    @Query("from OrderDetailsPo where paymentStatus = ?1 and orderStatus = ?2 and deliverGoods = ?3")
    List<OrderDetailsPo> findOrderDetails(Integer paymentStatus, Integer orderStatus,Integer deliverGoods);

    @Query("from OrderDetailsPo where paymentStatus = ?1 and orderStatus = ?2 and deliverGoods = ?3 and orderuser = ?4")
    List<OrderDetailsPo> findOrderDetailsAndEmail(Integer paymentStatus, Integer orderStatus,Integer deliverGoods,String email);

    @Modifying
    @Query("update OrderDetailsPo set deliverGoods = 1 where id = ?1")
    int UpOrderDetails(Integer id);


    @Modifying
    @Query("update OrderDetailsPo set paymentStatus = 1 where id = ?1")
    int UpOrderpay(Integer id);

    @Modifying
    @Query("update OrderDetailsPo set orderStatus = 1 where id = ?1")
    int confirmReceipt(Integer id);


}
